package com.example.service;

import com.example.entity.Employee;
import com.example.entity.User;
import com.example.mapper.EmployeeMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeService {

    @Resource
    EmployeeMapper empMapper;

    public void add(Employee emp) {
        empMapper.insert(emp);
    }

    public void deleteById(Integer id) {
        empMapper.deleteById(id);
    }

    public void updateById(Employee emp) {
        empMapper.updateById(emp);
    }

    public List<Employee> selectAll() {
        return empMapper.selectAll();
    }

    public Employee selectById(Integer id) {
        return empMapper.selectById(id);
    }

    public PageInfo<Employee> selectPage(Integer pageNum, Integer pageSize) {
        //开启分页查询
        PageHelper.startPage(pageNum, pageSize);
        List<Employee> list = empMapper.selectAll();
        return PageInfo.of(list);
    }
}
